import pl.drawing.Rysowanie
import templateGallery.mvcgallery.*
import templateGallery.mvc.*
import templateGallery.I.*
import flash.display.BitmapData
import templateGallery.util.Observable
import mx.transitions.Tween
import mx.transitions.easing.*


class templateGallery.mvcgallery.DescView extends AbstractView {
var __desc:TextField

function DescView(){}

/////////////////////////////////////////////////////////	

 public function defaultController (model:Observable):Controller {
   return new ImageController(model)
  }
  
////////////////////////////////////

function onHideImage(){
this.hide()	
}

///////////////////////////////////

function onLoad(){
	Stage.addListener(this)
	
}

////////////////////////////////////////////

function onResize(){
	this.onImageResize()	
}

///////////////////////////////////////////////////////////////////////////////////////// 

function onImageResize(){
	
	this.setPosition()
}

/////////////////////////////////////


private function setPosition(){
	var model:GalleryModel=GalleryModel(this.getModel())
	var gallery:Gallery=model.__target
	var image:ImageView=gallery.__image
	this._x=image._x-image.getWidth()/2
	this._y=image._y+image.getHeight()/2+10
	this.__desc._width=image.getWidth()
}

///////////////////////////////////

function shov(){
	this.__desc._visible=true
}

//////////////////

function hide(){
	this.__desc._visible=false	
}

///////////////////

function onHideEnd(){
	this.__desc.text=""
}

////////////////////////////////////////////////////////

function onIntroEnd(){
var desc=this.getDesc()
if(desc==undefined){desc=""}
var title=this.getTitle()
if(title==undefined){title=""}
this.shov()
this.__desc.autoSize=true
this.__desc.html=true
this.__desc.htmlText=desc
this.__desc._alpha=0
var w=new Tween(this.__desc,'_alpha',Strong.easeOut,this.__desc._alpha,100,.5,1)
}

////////////////////////

function getTitle(){
var model:GalleryModel=GalleryModel(this.getModel())
var attributes:Object=model.getAttributes()
var title=attributes.title
return title
}

///////////////////////////////////////////////////////////////////////////////

function getDesc(){
var model:GalleryModel=GalleryModel(this.getModel())
var attributes:Object=model.getAttributes()
return attributes.child.firstChild.nodeValue

}

/////////////////////////////////////////////////////////

function onExitStart(){
this.hide()	
}

//////////////////////////////////////////////////
	
}

